
#include "Muncher.h"
#include "MuncherShape.h"
#include "Controls.h"
#include "FontRender2D.h"

Muncher::Muncher()
{
	shape = new MuncherShape();

	name = L"Muncher";

	position->x = -2.0f;
	position->y = 0.6f;
	position->z = 1.5f;

	boardPosX = 0;
	boardPosY = 0;

}

Muncher::~Muncher() {}

void Muncher::Draw()
{

	SceneNode::Draw();

	   
}


void Muncher::Update(double frameTime)
{	
	SceneNode::Update(frameTime);

	if ( velocity->x > 0.0 ) //moving right
		if ( position->x >= boardPosX - 2 ) //TODO calcualte it based on bard size
		{
			velocity->x = 0.0;
			position->x = boardPosX - 2;
		}

	if ( velocity->x < 0.0 ) //moving left
		if ( position->x <= boardPosX - 2 )
		{
			velocity->x = 0.0;
			position->x = boardPosX - 2;
		}

	if ( velocity->z > 0.0 ) //moving right
		if ( position->z >= 1.5 - boardPosY )
		{
			velocity->z = 0.0;
			position->z = 1.5 - boardPosY;
		}

	if ( velocity->z < 0.0 ) //moving left
		if ( position->z <= 1.5 - boardPosY )
		{
			velocity->z = 0.0;
			position->z = 1.5 - boardPosY;
		}	

}

void Muncher::MoveTo(float x, float y, float z, float speed)
{
}

void Muncher::MoveLeft()
{
	SetVelocity(-4.0,0.0,0.0);
	boardPosX += -1;
}

void Muncher::MoveRight()
{
	SetVelocity(4.0,0.0,0.0);
	boardPosX += 1;
}

void Muncher::MoveUp()
{
	SetVelocity(0.0,0.0,4.0);
	boardPosY += -1;
}

void Muncher::MoveDown()
{
	SetVelocity(0.0,0.0,-4.0);
	boardPosY += 1;
}